#pragma once
#include <cstdint>
#include <atomic>

constexpr int MAX_CHANNELS = 64;
constexpr int MAX_PAYLOAD = 4096;

enum class ChannelPermission : uint8_t {
    NONE = 0,
    READ = 1,
    WRITE = 2,
    READWRITE = 3
};

struct Channel {
    std::atomic<uint32_t> futex_flag; // 0 = 空闲, 1 = 有数据
    uint32_t length;
    ChannelPermission permission;
    uint8_t payload[MAX_PAYLOAD];
};

struct SharedMemory {
    std::atomic<uint32_t> channel_bitmap; // 通道分配位图
    Channel channels[MAX_CHANNELS];
};
